#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
	int n = 0;
	scanf("%d", &n);
	int* a = (int*)malloc(sizeof(int) * n);
	if (a == NULL)
		exit(-1);
	int m = 0;
	int index = 0;
	while (scanf("%d", &m) != EOF)
	{
		if (m == -1)
			break;
		a[index++] = m;
	}
	int sum = 0;
	for (int j = 0; j < index; j++)
	{
		for (int i = 2; i <= sqrt(a[j]); i++)
		{
			if (a[j] % i == 0)
			{
				sum += i;
				sum += a[j] / i;
			}
		}
	}
	printf("%d", sum);
	return 0;
}